﻿using Gobang.Client.Common;
using Sunny.UI;

namespace Gobang.Client.View.FrmPage
{
    public partial class LeftPage : UIPage
    {
        private readonly MainPage _mainPage;
        public LeftPage(MainPage mainPage)
        {
            InitializeComponent();
            _mainPage = mainPage;
            uiTreeView1.ExpandAll();
            Bind();

        }
        private void Bind()
        {
            uiTreeView1.BeginUpdate();

            uiTreeView1.Nodes.AddRange(AreaCache.TreeNodes);

            uiTreeView1.EndUpdate();
            // 默认选中
            uiTreeView1.SelectedNode = AreaCache.TreeNodes.First().FirstNode;
        }

        private void uiTreeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            _mainPage?.SelectRoom(e);
        }

        private void LeftPage_FormClosing(object sender, FormClosingEventArgs e)
        {

        }
    }
}
